package com.aoxiang.zbox.common.model;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * Description:
 *
 * @author: aoxiang
 * @create: 2024-12-26 15:17
 **/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResultPageData<T> {
    private List<T> list;

    private PageInfo pageInfo;

    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    public static class PageInfo {
        // 当前页
        private int page;
        // 页大小
        private int pageSize;
        // 总页数
        private int totalPage;
        // 总条数
        private int totalNumber;

        // 获取数据为0
        public static PageInfo emptyPage(int page, int pageSize) {
            return PageInfo.builder()
                    .page(page)
                    .pageSize(pageSize)
                    .totalPage(0)
                    .totalNumber(0)
                    .build();
        }
    }
}
